﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;

namespace DAL
{
    public class DBHelper
    {
        private string StrCon = "server=.;database=GataBase;uid=sa;pwd=123456";
        public DataTable GetData(string StrSql) 
        {
            using (SqlConnection con=new SqlConnection(StrCon))
            {
                DataSet ds = new DataSet();
                con.Open();
                SqlDataAdapter sda = new SqlDataAdapter(StrSql,con);
                sda.Fill(ds);
                con.Close();
                return ds.Tables[0];
            }
        }

        public bool SetData(string StrSql)
        {
            using (SqlConnection con = new SqlConnection(StrCon))
            {
                bool result = false;
                con.Open();
                SqlCommand cmd = new SqlCommand(StrSql,con);
                result = cmd.ExecuteNonQuery() > 0;
                con.Close();
                return result;
            }
        }
    }
}
